﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;

public class SendMail
{
    public static int Mail(string EmailTo, string MailBody, string MailSubject)
    {
       // var dt = ConfigService.Config_GetByAll();
        //string eMail = dt.Rows[0]["Mail"].ToString();
        //string Pass = dt.Rows[0]["MailPassword"].ToString();
        string eMail = "vqthieuuit@gmail.com";
        string Pass = "0978872225";
        MailMessage mail = new MailMessage();
        SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
        mail.From = new MailAddress("Ban quản trị web<" + eMail + ">");
        mail.To.Add(EmailTo); //nhap dia chi mail gui den
        mail.Subject = MailSubject;
        mail.Body = MailBody;
        SmtpServer.Port = 587;
        SmtpServer.Credentials = new System.Net.NetworkCredential(eMail, Pass);
        SmtpServer.EnableSsl = true;
        try
        {
            SmtpServer.Send(mail);
            return 1;
        }
        catch
        {
            return 0;
        }
    }
}